#include "stdinclude.h"
#include "input/InputProcessor.h"
#include "input/InputSys.h"



InputProcessor::InputProcessor(InputSys* inputSystem) : 
	inputSystem(inputSystem)
{	
}


InputProcessor::~InputProcessor(void)
{
}

ProcessorResultEnum InputProcessor::runStep(long delta)
{
	//capture input from init devices
	inputSystem->captureInput();

	//bool appRunning

	if (appRunning)
		return continueloopProcessorResult;
	else
		return endloopProcessorResult;
}




//prepara per il loop
void InputProcessor::startup(void)
{
	appRunning=true;

	//inputSystem->test.connect(boost::bind(&InputProcessor::t,this,_1,_2));
	inputSystem->signalKeyPressed.connect(
		boost::bind(&InputProcessor::keypressed,this, _1)
		);
}

//fine loop
void InputProcessor::shutdown(void)
{
	//inputSystem->signalKeyPressed.disconnect(boost::bind(&InputProcessor::keypressed,this));	
}




void InputProcessor::keypressed(InputKeyCodeEnum keyCodeEnum)
{
	if(keyCodeEnum==InputKeyCodeEnum::KC_Q 
		|| keyCodeEnum==InputKeyCodeEnum::KC_ESCAPE)
	{
		appRunning=false;
	}
}